<template>
	<view class="m-content">
		<u-row customStyle="padding: 10rpx 0;background-color: rgb(242, 242, 242);"></u-row>
		<u-row :customStyle="bgstyle" gutter="8">
			<u-col span="2">
				<u-avatar size="46" :src="userInfo.avatar"></u-avatar>
			</u-col>
			<u-col span="10">
				<view>
					<u--text
						:text="userInfo.nickname"
						type="primary"
						bold
						size="15"
					></u--text>
				</view>
				<view style="padding-top: 10rpx;color: rgb(172, 172, 172);">
					<text>学院：</text><text>{{userInfo.college==null?'未知':userInfo.college}}</text>
				</view>
			</u-col>
		</u-row>
		<view class="v-bg-color">
			<u-row 
				gutter="4" 
				customStyle="padding: 20rpx 0;border-bottom: solid 1px rgb(242, 242, 242)" 
				v-for="(item,index) in itemList" 
				@click="toPage(item.url)"
				:key="index">
				<u-col span="2">
					<u-icon :name="item.icon" size="30"></u-icon>
				</u-col>
				<u-col span="8">
					<u--text
						:text="item.name"
						size="15"
					></u--text>
				</u-col>
			</u-row>
		</view>
		<view class="v-bg-color" style="width: 96%;text-align: center;">
			<text @click="logout()">退出登录</text>
		</view>
	</view>
</template>

<script>

	export default {
		data() {
			return {
				itemList: [
					//{icon: 'http://106.13.239.254/icon/my_monery.png', name: '我的钱包',url: 'pages/wallet/wallet'},
					// {icon: 'http://106.13.239.254/icon/my_address.png', name: '我的地址',url: 'pages/wallet/wallet'},
					{icon: 'http://106.13.239.254/icon/my_publish.png', name: '我发布的',url: 'pages/my-publish/my-publish'},
					{icon: 'http://106.13.239.254/icon/my_sale.png', name: '我卖出的',url: 'pages/order/order?sign=0'},
					{icon: 'http://106.13.239.254/icon/my_buy.png', name: '我买到的',url: 'pages/order/order?sign=1'},
					{icon: 'http://106.13.239.254/icon/my_authentication.png', name: '身份认证', url: 'pages/identity-verify/identity-verify'},
					{icon: 'email', name: '意见反馈', url: 'pages/feedback/feedback'},
				],
				bgstyle:'padding: 40rpx 20rpx;margin: 50rpx 10rpx;border-radius:10rpx;background-color: #fff',
				userInfo:{nickName: 'yexu!', avatarUrl: 'https://cdn.uviewui.com/uview/album/5.jpg'},
			}
		},
		onLoad() {
			this.userInfo = getApp().globalData.userInfo || JSON.parse(uni.getStorageSync("userInfo"))
		},
		methods: {	
			toPage(url){
				uni.$u.route(url);
			},
			logout(){
				console.log('登出...')
				getApp().globalData.userInfo = null
				uni.clearStorageSync()
				//跳转任意页面, 并关闭其它所有页面
				uni.$u.route({
					url: '/pages/login/login',
					type: 'reLaunch'
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	
	.m-content {
		min-height: 100vh;
		background-color: rgb(242, 242, 242);
		.v-bg-color {
			padding: 30rpx 20rpx;
			margin: 50rpx 10rpx;
			border-radius: 10rpx;
			background-color: #fff
		}
	}
	
</style>
